#ifndef __USER__SOCKET_H__
#define __USER__SOCKET_H__

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>



int user_socket_open(int type, int protocol, int port);

int user_socket_udp_open(int port);
int user_socket_tcp_open(int port);
int user_socket_tcp_connect(int socket_fd, const char *ip, int port, int timeout_ms);


int user_socket_send(int sock, const void *data, int timeout_ms);
int user_socket_sendto(int sockfd, const void *data, int len,const char *ip, int port, int timeout_ms);

int user_socket_recv(int socket_fd, char *buffer, int len, int timeout_ms);
int user_socket_recvfrom(int sockfd, char *pbuffer, int maxLen, int timeout_ms, char *out_addr);




int user_socket_block_enable(int fd, bool en);
int user_socket_bind(int sock, int port, const char * addr);
int user_socket_set_ip_multicast_loop(int sock_fd, int en);
int user_socket_set_so_broadcast(int sock, int en);
int user_socket_set_ip_add_memership(int sock_fd, const char *addr);
int user_socket_set_bindtodevice(int sock_fd, const char*name);
int user_socket_set_ip_multicast_if(int sock_fd, const char *name);
int user_socket_set_so_rcvbuf(int sockfd, unsigned int size);
int user_socket_set_so_sndbuf(int sockfd, unsigned int size);

int user_socket_network_card_get_ip(const char *nwkname, char *p_ip, char *p_mask, char *p_gateway);

#endif